﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminIndexMaster.master" AutoEventWireup="true" CodeFile="Admin_Specifications.aspx.cs" Inherits="Admin_Admin_Specifications" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <link href="Css/Css/specification/skin_0.css" rel="stylesheet" type="text/css" />
   <div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>规格管理</h3>
      <ul class="tab-base">
        <li><a class="current" href="javascript:void(0);"><span>管理</span></a></li>
        <li><a href="#"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <table id="prompt" class="table tb-type2">
    <tbody>
      <tr class="space odd">
        <th colspan="12" class="nobg"> <div class="title">
            <h5>操作提示</h5>
            <span class="arrow"></span> </div>
        </th>
      </tr>
      <tr class="odd">
        <td><ul>
            <li>规格将会对应到商品发布的规格，请详细添加。如：颜色;军绿色、天蓝色、巧克力色、桔色、浅灰色、浅绿色、浅黄色等等。</li>
            <li>当管理员添加类型时需选择规格，不同的类型可以选择相同的规格。</li>
          </ul></td>
      </tr>
    </tbody>
  </table>
    <input type="hidden" name="act" value="spec" />
    <input type="hidden" name="op" value="spec_del" />
    <table class="table tb-type2">
      <thead>
        <tr class="thead">
          <th></th>
          <th>排序</th>
          <th>规格名称</th>
          <th>规格值</th>
          <th class="align-center">操作</th>
        </tr>
      </thead>
      <tbody>
          <asp:Repeater ID="Repeater1" runat="server" 
              onitemcommand="Repeater1_ItemCommand">
          <ItemTemplate>
          <tr class="hover edit">
          <td class="w24">
           <input type="checkbox" class="checkitem" value='<%#Eval("sp_sort") %>' id="itemsbox" runat="server" />
          </td>
          <td class="w48 sort"><span class="tooltip editable" title="可编辑"><%#Eval("sp_sort")%></span></td>
          <td class="w270 name"><span><%#Eval("sp_name")%></span></td>
          <td class="name"><%#Eval("sp_value")%></td>
          <td class="w96 align-center"><a href="#">编辑</a> |
              <asp:LinkButton ID="linkDel" runat="server" CommandName="del" CommandArgument='<%#Eval("sp_id") %>' OnClientClick="return confirm('确定要删除吗?')">删除</asp:LinkButton>
          </td>
        </tr>
          </ItemTemplate>
          </asp:Repeater>
                      </tbody>
            <tfoot>
        <tr>
          <td><input type="checkbox" class="checkall" id="checkallBottom" value="check" onclick="checkAll(this)" /></td>
          <td id="dataFuncs" colspan="4"><label for="checkallBottom">全选</label>
              <asp:LinkButton ID="linkDelete" runat="server" CssClass="btn" 
                  OnClientClick="return checkop()" onclick="linkDelete_Click"><span>删除</span> </asp:LinkButton>
            <div class="pagination"> <%--<ul><li><span>首页</span></li><li><span>上一页</span></li><li><span class="currentpage">1</span></li><li><span>下一页</span></li><li><span>末页</span></li></ul>--%>
            <ul><asp:Literal ID="ltrPage" runat="server"></asp:Literal></ul>
            
             </div></td></tr>
        </tfoot>
          </table>
</div>
    <link href="../Skin/CommStyle/jquery.tooltip.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/Witkey/resource/js/jquery.js"></script>
    <script src="../Skin/CommStyle/js/jquery.validate.min.js" type="text/javascript"></script>
    <script src="Js/admincp.js" type="text/javascript"></script>
    <script src="../Skin/CommStyle/js/jquery.cookie.js" type="text/javascript"></script>
    <script src="../Skin/CommStyle/js/jquery.tooltip.js" type="text/javascript"></script>    <link href="Css/Css/specification/skin_0.css" rel="stylesheet" type="text/css" id="cssfile2" />
<script type="text/javascript">
    //换肤
    cookie_skin = $.cookie("MyCssSkin");
    if (cookie_skin) {
        $('#cssfile2').attr("href", "Css/Css/specification/" + cookie_skin + ".css");
    } 
</script>


<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>规格管理</h3>
      <ul class="tab-base">
        <li><a href="index.php?act=spec&op=spec"><span>管理</span></a></li>
        <li><a class="current" href="JavaScript:void(0);"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="spec_form" method="post" enctype="multipart/form-data">
    <input type="hidden" value="ok" name="form_submit" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td class="required" colspan="2"><label class="validation" for="s_name">规格名称</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" class="txt" name="s_name" id="s_name" /></td>
          <td class="vatop tips">请填写常用的商品规格的名称；例如：颜色；尺寸等。</td>
        </tr>
        <tr>
          <td class="required" colspan="2"><label class="validation" for="s_sort">排序</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" class="txt" name="s_sort" id="s_sort" value="0" /></td>
          <td class="vatop tips">请填写自然数。规格列表将会根据排序进行由小到大排列显示。</td>
        </tr>
        <tr>
          <td class="required" colspan="2"><label>规格类型</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><ul>
              <li>
                <input type="radio" name="s_dtype" id="s_dtype_text" value="text" checked="checked" />
                <label for="s_dtype_text">文字</label>
              </li>
              <li>
                <input type="radio" name="s_dtype" id="s_dtype_image" value="image" />
                <label for="s_dtype_image">图片</label>
              </li>
            </ul></td>
          <td class="vatop tips">图片类型的规格值用于直观表现某些特殊规格类型，例如颜色规格，可用对应的色彩图片来表现其各种颜色值。</td>
        </tr>
        </tbody></table>
        <table class="table tb-type2">
              <thead class="thead">
              <tr class="space"><th colspan="15"><label>添加规格值</label></th></tr>
                <tr class="noborder">
                  <th>排序</th>
                  <th>规格值</th>
                  <th class="image_display">规格图片</th>
                  <th></th>
                  <th class="align-center">操作</th>
                </tr>
              </thead>
              <tbody id="tr_model">
              	<tr></tr>
                <tr class="hover edit">
                  <td class="w48 sort"><input type="text" name="s_value[key][sort]" value="0" /></td>
                  <td class="name w270"><input type="text" name="s_value[key][name]" value="" /></td>
                  <td class="image_display vatop rowform w300">
                  <span class="type-file-show"><img class="low_source" width="16" height="16" src="http://127.0.0.1:86/shopnc/admin/templates/images/transparent.gif"></span><span class="type-file-box">
                    <input type="text" name="textfield" class="type-file-text" /><input type="button" name="button" value="" class="type-file-button" />
                    <input class="type-file-file" type="file" title="" nc_type="change_default_goods_image" hidefocus="true" size="30" name="s_value_key"></span></td><td></td>
                  <td class="w150 align-center"><a onclick="remove_tr($(this));" href="JavaScript:void(0);">移除</a></td>
                </tr>
              </tbody>
              <tbody>
                <tr>
                  <td colspan="15"><a class="btn-add marginleft" id="add_type" href="JavaScript:void(0);"> <span>添加一个规格值</span> </a></td>
                </tr>
              </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15"><a id="submitBtn" class="btn" href="JavaScript:void(0);"> <span>提交</span> </a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript">
    $(function () {
        var i = 0;
        var tr_model = '<tr class="hover edit">' +
		'<td class="w48 sort"><input type="text" name="s_value[key][sort]" value="0" /></td>' +
		'<td class="w270 name"><input type="text" name="s_value[key][name]" value="" /></td>' +
		'<td class="w300 image_display vatop rowform">' +
			'<span class="type-file-show">' +
				'<img class="low_source" width="16" height="16" src="tpl/img/transparent.gif">' +
			'</span>' +
			'<span class="type-file-box">' +
				'<input type="text" name="textfield" class="type-file-text" /><input type="button" name="button" value="" class="type-file-button" />' +
				'<input class="type-file-file" type="file" title="" nc_type="change_default_goods_image" hidefocus="true" size="30" name="s_value_key">' +
			'</span>' +
		'</td>' +
		'<td></td><td class="w150 align-center"><a onclick="remove_tr($(this));" href="JavaScript:void(0);">移除</a></td>' +
	'</tr>';
        $("#add_type").click(function () {
            $('#tr_model > tr:last').after(tr_model.replace(/key/g, i));
            if ($('.image_display').is(":hidden")) {
                $('.image_display').hide();
            }
            $.getScript("../resource/js/admincp.js");
            i++;
        });

        //规格图片显示与隐藏操作
        $('.image_display').hide();
        $('#s_dtype_image').click(function () {
            $('.image_display').show();
        });
        $('#s_dtype_text').click(function () {
            $('.image_display').hide();
        });

        //表单验证
        $('#spec_form').validate({
            errorPlacement: function (error, element) {
                error.appendTo(element.parent().parent().prev().find('td:first'));
            },
            success: function (label) {
                label.addClass('valid');
            },
            onkeyup: false,
            rules: {
                s_name: {
                    required: true,
                    maxlength: 10,
                    minlength: 1
                },
                s_sort: {
                    required: true,
                    digits: true
                }
            },
            messages: {
                s_name: {
                    required: '请填写规格名称',
                    maxlength: '规格名称长度应在1-10个字符之间',
                    minlength: '规格名称长度应在1-10个字符之间'
                },
                s_sort: {
                    required: '请填写规格排序',
                    digits: '请填写整数'
                }
            }
        });

        //按钮先执行验证再提交表单
        $("#submitBtn").click(function () {
            if ($("#spec_form").valid()) {
                $("#spec_form").submit();
            }
        });

        //预览图片
        $("input[nc_type='change_default_goods_image']").live("change", function () {
            var src = getFullPath($(this)[0]);
            $(this).parent().prev().find('.low_source').attr('src', src);
        });

    });

    function remove_tr(o) {
        o.parents('tr:first').remove();
    }
</script>

<script type="text/javascript">
    $(function () {
        $('input[nc_type="change_default_goods_image"]').live("change", function () {
            $(this).parent().find('input[class="type-file-text"]').val($(this).val());
        });
    });
</script> 
<script type="text/javascript">
    $(function () {
        $(function () {
            // 商品自动上下架
            var COOKIE_NAME = 'goods_commodity_scanning';
            var date = new Date();
            date.setTime(date.getTime() + (60 * 60 * 1000)); // cookie过期时间  单位毫秒 默认1小时
            if (!$.cookie(COOKIE_NAME)) {
                $('body').append('<iframe style="display:none" src="http://127.0.0.1:86/shopnc/admin/index.php?act=index&op=goods_commodity_scanning"></iframe>');
                $.cookie(COOKIE_NAME, 'test', { path: '/', expires: date });
            }


            // 过期店铺自动关闭，商品自动下架
            var COOKIE_NAME_S = 'shops_shut_down';
            date.setTime(date.getTime() + (24 * 60 * 60 * 1000)); // cookie过期时间 单位毫秒 默认1天
            if (!$.cookie(COOKIE_NAME_S)) {
                $('body').append('<iframe style="display:none" src="http://127.0.0.1:86/shopnc/admin/index.php?act=index&op=shops_shut_down"></iframe>');
                $.cookie(COOKIE_NAME_S, 'test', { path: '/', expires: date });
            }
        });
    });
</script>
      <script type="text/javascript">
          //以“全选”参数复选框作为参数
          function checkAll(chk) {
              var inputs = document.getElementsByTagName("input");

              //循环判断是否是复选框
              for (var i = 0; i < inputs.length; i++) {
                  if (inputs[i].type == "checkbox" && inputs[i].value != "check") {
                      inputs[i].checked = chk.checked;
                  }
              }
          }
          function checkop() {
              var checkok = false;
              var e = document.getElementsByTagName("input");
              for (var i = 0; i < e.length; i++) {
                  if (e[i].type == "checkbox" && e[i].value != "check") {
                      if (e[i].checked == true) {
                          checkok = true;
                          break;
                      }
                  }
              }
              if (checkok)
                  return confirm('删除后不可以恢复！确定要删除吗？');
              else {

                  alert("至少选择一个!");
                  return false;
              }
          }

    </script>
</asp:Content>

